//
//  DKContactAuthMobileView.m
//  DanKU
//
//  Created by 蓝鳍互娱 on 2023/11/27.
//

#import "DKContactAuthMobileView.h"
@interface DKContactAuthMobileView()<UITextFieldDelegate>
@property (nonatomic,strong) UILabel *dk_ContactAuthSelectHeadLab;
@property (nonatomic,strong) UITextField *dk_ContactAuthSelectContentField;
@end
@implementation DKContactAuthMobileView
-(instancetype)init{
    if(self == [super init]){
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    UIView * dk_ContactAuthSelectBgView = [[UIView alloc] init];
    dk_ContactAuthSelectBgView.layer.cornerRadius = DK_IsWidthScale(14);
    dk_ContactAuthSelectBgView.backgroundColor = DK_Hex(@"#F7F7F8");
    [self addSubview:dk_ContactAuthSelectBgView];
    [dk_ContactAuthSelectBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(0)));
        make.right.equalTo(@(-DK_IsWidthScale(0)));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(-DK_IsWidthScale(0)));
    }];
    self.dk_ContactAuthSelectHeadLab = [[UILabel alloc] init];
    self.dk_ContactAuthSelectHeadLab.textColor = DK_Hex(@"#999999");
    self.dk_ContactAuthSelectHeadLab.font = DK_FONT_Medium(14);
    self.dk_ContactAuthSelectHeadLab.text = @"Mobile";
    [dk_ContactAuthSelectBgView addSubview:self.dk_ContactAuthSelectHeadLab];
    [self.dk_ContactAuthSelectHeadLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(15)));
        make.width.equalTo(@(DK_IsWidthScale(75)));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(DK_IsWidthScale(0)));
    }];
    self.dk_ContactAuthSelectContentField = [[UITextField alloc] init];
    self.dk_ContactAuthSelectContentField.textColor = DK_Hex(@"#333333");
    self.dk_ContactAuthSelectContentField.font = DK_FONT_Medium(14);
    self.dk_ContactAuthSelectContentField.placeholder = @"Automatic entry";
    self.dk_ContactAuthSelectContentField.keyboardType = UIKeyboardTypeNumberPad;
    self.dk_ContactAuthSelectContentField.textAlignment = NSTextAlignmentRight;
    self.dk_ContactAuthSelectContentField.delegate = self;
    [self.dk_ContactAuthSelectContentField addTarget:self action:@selector(fieldEditChange) forControlEvents:UIControlEventEditingChanged];
    [self addSubview:self.dk_ContactAuthSelectContentField];
    [self.dk_ContactAuthSelectContentField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dk_ContactAuthSelectHeadLab.mas_right);
        make.right.equalTo(@(-DK_IsWidthScale(15)));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(DK_IsWidthScale(0)));
    }];
}
- (void)fieldEditChange{
    if(self.InputScuessBlock){
        self.InputScuessBlock();
    }
}
-(void)setContactAuthMobile:(NSString *)contactAuthMobile{
    _contactAuthMobile = contactAuthMobile;
    self.dk_ContactAuthSelectContentField.text = _contactAuthMobile;
}
- (NSString *)getContactAuthMobile{
    return self.dk_ContactAuthSelectContentField.text;
}
#pragma mark UITextFieldDelegate
-(void)textFieldDidBeginEditing:(UITextField *)textField{//开始编辑
    NSString * ship = DK_ActionContact1_Info_Focus;
    if(_authContactAuthSigleType == AuthContactAuthSigleTypeContactSecond){
        ship = DK_ActionContact2_Info_Focus;
    }
    [DKPublicHttp apiUserBrhavRecordForAPI:@{} withPageName:DK_VerifyContact withAction:ship complete:^{
            
    } fail:^{
            
    }];
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
    NSString * dk_baseInfoText = [textField.text stringByReplacingCharactersInRange:range withString:string];
    if(self.InputScuessBlock){
        self.InputScuessBlock();
    }
    return YES;
}
@end
